home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 62 / Quick PC 62.iso / I386 / IIS5_01.CAB / IIS_Cookie_JScript.asp < prev    next >
Encoding:
Text File  |  1998-09-16  |  1.8 KB  |  68 lines

  1. <%@ LANGUAGE = JScript %>
  2.  
  3. <!*************************
  4. This sample is provided for educational purposes only. It is not intended to be 
  5. used in a production environment, has not been tested in a production environment, 
  6. and Microsoft will not provide technical support for it. 
  7. *************************>
  8.  
  9. <%
  10.     //Changes to the HTTP response header, in which cookies
  11.     //are sent back to the client, must be made before
  12.     //sending any data to the user.
  13.     
  14.     Response.Expires = 0;
  15.     
  16.     
  17.     //Get the last visit date/time string from the cookie that
  18.     //resides in the HTTP request header.
  19.     
  20.     var LastVisitCookie;
  21.     LastVisitCookie = Request.Cookies("CookieJScript");
  22.     
  23.     
  24.     //Send the current date/time string in a cookie enclosed
  25.     //in the response header. Note that because IE now uses
  26.     //case-sensitive cookie paths, we have explicitly set
  27.     //the cookie path to be that of the URL path to this
  28.     //page. By default, the path would be that of the
  29.     //IIS Application context for this page ("IISSAMPLES").
  30.     
  31.     var CurrentDate = new Date();
  32.     Response.Cookies("CookieJScript") = CurrentDate.toLocaleString();
  33. %>
  34.  
  35. <HTML>
  36.     <HEAD>
  37.         <TITLE>Using Cookies</TITLE>
  38.     </HEAD>
  39.  
  40.     <BODY BGCOLOR="White" TOPMARGIN="10" LEFTMARGIN="10">
  41.  
  42.         <FONT SIZE="4" FACE="ARIAL, HELVETICA">
  43.         <B>Using Cookies</B></FONT><BR>
  44.       
  45.         <HR SIZE="1" COLOR="#000000">
  46.         
  47.         <%
  48.             if (LastVisitCookie == "") 
  49.             {
  50.                 //The cookie has never been set. This must
  51.                 //be the user's first visit to this page.
  52.                 
  53.                 Response.Write("Welcome to this page.");
  54.             }
  55.             else
  56.             {
  57.                 //Remind the user of the last time she/he
  58.                 //visited this page.
  59.  
  60.                 Response.Write("You last visited this page on " + LastVisitCookie);
  61.             }        
  62.         %>
  63.  
  64.         <P><A HREF="Cookie_JScript.asp">Revisit This Page</A>
  65.  
  66.     </BODY>
  67. </HTML>
  68.